<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <script type="text/javascript" src="<%=path %>/js/jquery-1.8.3.js"></script>
    <base href="<%=basePath%>">
    <script type="text/javascript">
    var id = ${param.id}
    	$(function(){
    		$.post(
    			"<%=path%>/work/findObjectById.controller",
    			{
    				"id":id,
    			},
    			function(resu){
    				$.post(
    				"<%=path%>/work/findCompanyList.controller",
    				function(result){
    					for(var i in result){
    					console.log(result)
    						$("#cid").append("<option class='he' value='"+result[i].cid+"'>"+result[i].cname+"</option>")
    					}
    					$(".he[value='"+resu.cid+"']").attr("selected","selected");
    				},
    				"json"
    			)
    			$.post(
    				"<%=path%>/work/findPositionList.controller",
    				function(result){
    					for(var i in result){
    					console.log(result)
    						$("#pid").append("<option class='h' value='"+result[i].pid+"'>"+result[i].pname+"</option>")
    					}
    					$(".h[value='"+resu.pid+"']").attr("selected","selected");
    				},
    				"json"
    			)
    		$("#name").val(resu.name)
    		$("#age").val(resu.age)
    		$("#hobby").val(resu.hobby)
    			},
    			"json"
    		)
    		
    	
    	});
    
    </script>
    
  </head>
  
  <body>
   		<form action="<%=path%>/work/update.controller" method="post">
   		<input type="hidden" name="id" value="${param.id }">
   			<table>
   					<tr>
   							<td>
   					姓名:<input type="text" name="name" id="name">
  						
   							</td>
   							
   					</tr>
   					<tr>
   							<td>
   					年龄:<input type="text" name="age" id="age">
  						
   							</td>
   							
   					</tr>
   					<tr>
   							<td>
   					爱好:<input type="text" name="hobby" id="hobby">
  						
   							</td>
   							
   					</tr>
   					
   					<tr>
   							<td>
   					公司:
   					<select name="cid" id="cid">
   						
   					</select>
  						
   							</td>
   							
   					</tr>
   					<tr>
   							<td>
   					职位:
   					<select name="pid" id="pid">
   					</select>
  						
   							</td>
   							
   					</tr>
   					<tr>
   							<td>
   					<input type="submit" value="修改" >
  						
   							</td>
   							
   					</tr>
   			</table>
   		
   		</form>
  </body>
</html>
